<?xml version='1.0' encoding='UTF-8' ?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
	   xmlns:my='http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-12-14T10:15:01'>
	<xsl:output method='xml' standalone='yes' />
	<xsl:template match='my:myFields'>
		<DynamicEntity Name='csp_wastecollection' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
        xmlns:xsd='http://www.w3.org/2001/XMLSchema' >
			<Properties xmlns='http://schemas.microsoft.com/crm/2006/WebServices'>


				<xsl:if test='//my:CitizenAddress/text()'>
					<Property xsi:type='StringProperty' Name='csp_address'>
						<Value><xsl:value-of select='//my:CitizenAddress'/></Value>
					</Property>
				</xsl:if>


				<xsl:if test='//my:CitizenCity/text()'>
					<Property xsi:type='StringProperty' Name='csp_city'>
						<Value><xsl:value-of select='//my:CitizenCity'/></Value>
					</Property>
				</xsl:if>

				<xsl:if test='//my:CitizenZip/text()'>
					<Property xsi:type='StringProperty' Name='csp_postalcode'>
						<Value><xsl:value-of select='//my:CitizenZip'/></Value>
					</Property>
				</xsl:if>

				<xsl:if test='//my:CitizenEmail/text()'>
					<Property xsi:type='StringProperty' Name='csp_emailaddress'>
						<Value><xsl:value-of select='//my:CitizenEmail'/></Value>
					</Property>
				</xsl:if>

				<xsl:if test='//my:CitizenPhone/text()'>
					<Property xsi:type='StringProperty' Name='csp_phone'>
						<Value><xsl:value-of select='//my:CitizenPhone'/></Value>
					</Property>
				</xsl:if>

				<xsl:if test='//my:CitizenFax/text()'>
					<Property xsi:type='StringProperty' Name='csp_fax'>
						<Value><xsl:value-of select='//my:CitizenFax'/></Value>
					</Property>
				</xsl:if>

				<xsl:if test='//my:chkMonday/text()'>
					<Property xsi:type='CrmBooleanProperty' Name='csp_mondaypreferred'>
						<Value><xsl:value-of select='//my:chkMonday'/></Value>
					</Property>
				</xsl:if>

				<xsl:if test='//my:chkTuesday/text()'>
					<Property xsi:type='CrmBooleanProperty' Name='csp_tuesdaypreferred'>
						<Value><xsl:value-of select='//my:chkTuesday'/></Value>
					</Property>
				</xsl:if>

				<xsl:if test='//my:chkWednesday/text()'>
					<Property xsi:type='CrmBooleanProperty' Name='csp_wednesdaypreferred'>
						<Value><xsl:value-of select='//my:chkWednesday'/></Value>
					</Property>
				</xsl:if>

				<xsl:if test='//my:chkThursday/text()'>
					<Property xsi:type='CrmBooleanProperty' Name='csp_thursdaypreferred'>
						<Value><xsl:value-of select='//my:chkThursday'/></Value>
					</Property>
				</xsl:if>

				<xsl:if test='//my:chkFriday/text()'>
					<Property xsi:type='CrmBooleanProperty' Name='csp_fridaypreferred'>
						<Value><xsl:value-of select='//my:chkFriday'/></Value>
					</Property>
				</xsl:if>

				<xsl:if test='//my:rbWasteCollectionTime/text()'>
					<Property xsi:type='PicklistProperty' Name='csp_timeofday'>
						<xsl:choose>
							<xsl:when test="//my:rbWasteCollectionTime='Morning'">
								<Value>1</Value>
							</xsl:when>
							<xsl:when test="//my:rbWasteCollectionTime='Afternoon'">
								<Value>2</Value>
							</xsl:when>
							<xsl:otherwise>
								<Value>1</Value>
							</xsl:otherwise>
						</xsl:choose>
					</Property>
				</xsl:if>


				<xsl:if test='//my:WasteType/text()'>
					<Property xsi:type='PicklistProperty' Name='csp_type'>
						<xsl:choose>
							<xsl:when test="//my:WasteType='Industrial'">
								<Value>1</Value>
							</xsl:when>
							<xsl:when test="//my:WasteType='Domestic'">
								<Value>2</Value>
							</xsl:when>
							<xsl:otherwise>
								<Value>100</Value>
							</xsl:otherwise>
						</xsl:choose>
					</Property>
				</xsl:if>

				<xsl:if test='//my:WasteDescription/text()'>
					<Property xsi:type='StringProperty' Name='csp_wastedescription'>
						<Value><xsl:value-of select='//my:WasteDescription'/></Value>
					</Property>
				</xsl:if>

				<xsl:if test='//my:WasteAddress/text()'>
					<Property xsi:type='StringProperty' Name='csp_wastecollectionaddress'>
						<Value><xsl:value-of select='//my:WasteAddress'/></Value>
					</Property>
				</xsl:if>

				<xsl:if test='//my:WasteCity/text()'>
					<Property xsi:type='StringProperty' Name='csp_wastecollectioncity'>
						<Value><xsl:value-of select='//my:WasteCity'/></Value>
					</Property>
				</xsl:if>

				<xsl:if test='//my:WasteZIP/text()'>
					<Property xsi:type='StringProperty' Name='csp_wastecollectionpostalcode'>
						<Value><xsl:value-of select='//my:WasteZIP'/></Value>
					</Property>
				</xsl:if>

			</Properties>
		</DynamicEntity>
	</xsl:template>
</xsl:stylesheet>
